package com.godyao.dao.autowire;

import com.godyao.framework.beans.factory.annotaions.Autowired;
import com.godyao.framework.beans.factory.annotaions.Value;
import com.godyao.framework.stereotype.Component;
import com.godyao.framework.stereotype.Service;
import com.godyao.service.dynamic.IUserService;

import java.util.Random;

@Service
public class UserService implements IUserService {
    @Value("${token}")
    private String token;

    @Autowired
    private UserDao userDao;

    public String queryUserInfo() {
        try {
            Thread.sleep(new Random(1).nextInt(100));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return userDao.queryUserName("10001") + "，" + token;
    }

    @Override
    public void register(String username) {
        System.out.println(username);
    }

    @Override
    public String toString() {
        return "UserService{" +
                "token='" + token + '\'' +
                '}';
    }
}
